// pages/bank_card/bank_card.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var keyword = options.keyword;
    if (keyword != '' && keyword != undefined) {
      wx.setStorageSync('keyword', keyword)
      this.setData({
        keyword: keyword
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getHospital();
  },
  getHospital: function () {
    var that = this;
    app.util.request({
      'url': "entry/wxapp/regin.hospitals",
      data: {
        openid: wx.getStorageSync('openid'),
      },
      success: function (res) {
        that.setData({
          info: res.data
        })
      }
    })
  },
  see_detail: function (e) {
    var keyword = wx.getStorageSync('keyword');
    if(e.currentTarget.dataset.id == '')
    {
      wx.navigateTo({
        url: '/hyb_yl/jigou/pages/set_bankcard/set_bankcard?id=' + e.currentTarget.dataset.id,
      })
    }else if (keyword == 'tixian') {
      let pages = getCurrentPages();
      let prevPage = null; //上一个页面
      if (pages.length >= 2) {
        prevPage = pages[pages.length - 2]; //上一个页面
      }
      if (prevPage) {
        prevPage.setData({
          bank_card: e.currentTarget.dataset.number,
          bank_address:e.currentTarget.dataset.bank_name,
          bank_user:e.currentTarget.dataset.name,
          bank_id:e.currentTarget.dataset.id
        });
        wx.setStorageSync('keyword', '')
      }
      wx.navigateBack({})
    }else{
      wx.navigateTo({
        url: '/hyb_yl/jigou/pages/set_bankcard/set_bankcard?id=' + e.currentTarget.dataset.id,
      })
    }
    
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})